package com.hongshan.wallet.core.wallet

import android.databinding.ObservableField
import android.view.View
import com.hongshan.wallet.Constant
import com.hongshan.wallet.MyApplication
import com.hongshan.wallet.base.MyViewModel
import com.hongshan.wallet.bean.BindInfoBean
import com.hongshan.wallet.router.RouterIndex
import com.hongshan.wallet.router.go

/**
 * Copyright Zhangxx.
 * Copyright (c) 2019
 * All rights reserved
 *
 * @project  : Wallet
 * @package  : com.hongshan.wallet.core.wallet
 * @author   : zhangxx
 * @date     : 2019/5/23
 * @email    : qq957413212@hotmail.com
 * @desc     : //TODO
 */
class AccountTypeItemViewModel(val bindInfoBean: BindInfoBean) : MyViewModel(MyApplication.applicationContext) {
    val bg = ObservableField(Constant.HttpApi.BASE_URL+bindInfoBean.bg_img)
    val icon = ObservableField(Constant.HttpApi.BASE_URL+bindInfoBean.logo)
    val state = ObservableField<String>()
    val text = ObservableField<String>(bindInfoBean.type_dec)
    val enable = ObservableField<Boolean>(bindInfoBean.status != -3)
    val click = View.OnClickListener {
        when(bindInfoBean.type){
            1 -> { goBind() }
            2 -> { goBind() }
            3 -> {}
            4 -> {}
            5 -> {}
            6 -> {}
            7 -> { goBind() }
        }
    }

    init {
        state.set(when(bindInfoBean.status){
            1 -> "启用"
            0 -> "禁用"
            -2 -> "未设置"
            -3 -> "支付方式关闭"
            else -> null
        })
    }

    fun goBind(){
        go(
            RouterIndex.BIND_ACCOUNT,
            mapOf(
                Constant.ROUTE_PARAMS_KEY.BIND_ACCOUNT_TYPE to bindInfoBean.account_type,
                Constant.ROUTE_PARAMS_KEY.BIND_ACCOUNT_DATA to bindInfoBean
            )
        )
    }
}